'\" te
.\"  Copyright (c) 1998, Sun Microsystems, Inc.   All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PAM_SM_SETCRED 3PAM "August 19, 2023"
.SH NAME
pam_sm_setcred \- service provider implementation for pam_setcred
.SH SYNOPSIS
.nf
\fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lpam\fR [ \fIlibrary\fR ... ]
#include <security/pam_appl.h>
#include <security/pam_modules.h>



\fBint\fR \fBpam_sm_setcred\fR(\fBpam_handle_t *\fR\fIpamh\fR, \fBint\fR \fIflags\fR, \fBint\fR \fIargc\fR,
     \fBconst char **\fR\fIargv\fR);
.fi

.SH DESCRIPTION
In response to a call to \fBpam_setcred\fR(3PAM), the  \fBPAM\fR framework
calls \fBpam_sm_setcred()\fR from the modules listed in the \fBpam.conf\fR(5)
file.  The authentication provider supplies the back-end functionality for this
interface function.
.sp
.LP
The \fBpam_sm_setcred()\fR function is called to set the credentials of the
current user associated with the authentication handle, \fIpamh\fR. The
following flags may be set in the \fIflags\fR field.  Note that the first four
flags are mutually exclusive:
.sp
.ne 2
.na
\fB\fBPAM_ESTABLISH_CRED\fR\fR
.ad
.RS 25n
Set user credentials for the authentication service.
.RE

.sp
.ne 2
.na
\fB\fBPAM_DELETE_CRED\fR\fR
.ad
.RS 25n
Delete user credentials associated with the authentication service.
.RE

.sp
.ne 2
.na
\fB\fBPAM_REINITIALIZE_CRED\fR\fR
.ad
.RS 25n
Reinitialize user credentials.
.RE

.sp
.ne 2
.na
\fB\fBPAM_REFRESH_CRED\fR\fR
.ad
.RS 25n
Extend lifetime of user credentials.
.RE

.sp
.ne 2
.na
\fB\fBPAM_SILENT\fR\fR
.ad
.RS 25n
Authentication service should not generate messages
.RE

.sp
.LP
If no flag is set, \fBPAM_ESTABLISH_CRED\fR is used as the default.
.sp
.LP
The \fIargc\fR argument represents the number of module options passed in from
the configuration file \fBpam.conf\fR(5). \fIargv\fR specifies the module
options, which are interpreted and processed by the authentication service.  If
an unknown option is passed to the  module, an error should be logged and the
option ignored.
.sp
.LP
If the  \fBPAM_SILENT\fR flag is not set, then \fBpam_sm_setcred()\fR should
print any failure status from the corresponding  \fBpam_sm_authenticate()\fR
function using the conversation function.
.sp
.LP
The authentication status (success or reason for failure) is saved as
module-specific state in the authentication handle by the authentication
module. The status should be retrieved using \fBpam_get_data()\fR, and used to
determine if user credentials should be set.
.SH RETURN VALUES
Upon successful completion,  \fBPAM_SUCCESS\fR should be returned. The
following values may also be returned upon error:
.sp
.ne 2
.na
\fB\fBPAM_CRED_UNAVAIL\fR\fR
.ad
.RS 20n
Underlying authentication service can not retrieve user credentials.
.RE

.sp
.ne 2
.na
\fB\fBPAM_CRED_EXPIRED\fR\fR
.ad
.RS 20n
User credentials have expired.
.RE

.sp
.ne 2
.na
\fB\fBPAM_USER_UNKNOWN\fR\fR
.ad
.RS 20n
User unknown to the authentication service.
.RE

.sp
.ne 2
.na
\fB\fBPAM_CRED_ERR\fR\fR
.ad
.RS 20n
Failure in setting user credentials.
.RE

.sp
.ne 2
.na
\fB\fBPAM_IGNORE\fR\fR
.ad
.RS 20n
Ignore underlying authentication module regardless of whether the control flag
is \fIrequired\fR, \fIoptional\fR, or \fIsufficient\fR.
.RE

.SH ATTRIBUTES
See \fBattributes\fR(7) for description of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	 Stable
_
MT-Level	MT-Safe with exceptions
.TE

.SH SEE ALSO
.BR pam (3PAM),
.BR pam_authenticate (3PAM),
.BR pam_get_data (3PAM)
.BR libpam (3LIB),
.BR pam_setcred (3PAM),
.BR pam_sm_authenticate (3PAM),
.BR pam.conf (5),
.BR attributes (7)
.SH NOTES
The \fBpam_sm_setcred()\fR function is passed the same module options that are
used by \fBpam_sm_authenticate()\fR.
.sp
.LP
The interfaces in \fBlibpam\fR(3LIB) are MT-Safe only if each thread within the
multithreaded application uses its own \fBPAM\fR handle.
.sp
.LP
If the \fBPAM_REPOSITORY\fR \fIitem_type\fR is set and a service module does
not recognize the type, the service module does not process any information,
and returns \fBPAM_IGNORE\fR. If the \fBPAM_REPOSITORY\fR \fIitem_type\fR is
not set, a service module performs its default action.
